package com.neuedu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neuedu.common.ResultJson;
import com.neuedu.entity.RegistLevel;
import com.neuedu.service.RegistLevelService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 挂号级别表 前端控制器
 * </p>
 *
 * @author LiYang
 * @since 2024-11-07
 */
@RestController
@RequestMapping("/registLevel")
public class RegistLevelController {
    @Resource
    RegistLevelService registLevelService;
    @GetMapping("/list")
    ResultJson<IPage<RegistLevel>> list(Integer pageNo, Integer pageSize, String name) {
        return ResultJson.success(registLevelService.list(pageNo, pageSize, name));
    }
    @PostMapping("/add")
    ResultJson<Boolean> add(String code, String name, Integer fee, Integer quota, Integer sequenceNo) {
        return ResultJson.success(registLevelService.add(code, name, fee, quota, sequenceNo), "添加挂号级别成功");
    }
    @PostMapping("/update")
    ResultJson<Boolean> update(Long id, String code, String name, Integer fee, Integer quota, Integer sequenceNo) {
        return ResultJson.success(registLevelService.update(id, code, name,fee, quota, sequenceNo), "修改挂号级别成功");
    }
    @PostMapping("/del")
    ResultJson<Boolean> del(Long id, Boolean delmark) {
        return ResultJson.success(registLevelService.del(id, delmark), delmark ? "还原挂号级别成功" : "删除挂号级别成功");
    }
    @GetMapping("/getById")
    ResultJson<RegistLevel> getById(Long id) {
        return ResultJson.success(registLevelService.getById(id));
    }
    @GetMapping("/check")
    ResultJson<Boolean> check(String field, String value, Long id) {
        return ResultJson.success(registLevelService.check(field, value, id));
    }

    /**
     * 获取所有有效的挂号级别
     * @return
     */
    @GetMapping("/getActive")
    List<RegistLevel> getActive() {
        return registLevelService.getActive();
    }
}
